﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
			 xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
			 xmlns:mvvmLightCommand="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"
			 xmlns:behaviors="clr-namespace:Rio.Manager.Application.Behaviors"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
			 xmlns:Rio_Framework_Pages_Controls="clr-namespace:Rio.Framework.Pages.Controls;assembly=Rio.Framework.Pages"
			 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"             
			 x:Class="Rio.Manager.Application.Views.GroupAssociationTabView"
			 mc:Ignorable="d"
			 d:DesignHeight="768"
			 d:DesignWidth="1024">

	<UserControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="/Rio.Manager.Application;component/Skins/GroupAssociationTabSkin.xaml" />
			</ResourceDictionary.MergedDictionaries>
		</ResourceDictionary>
		<Style x:Key="BorderStyleGroupAssociation" TargetType="Border">
			<Setter Property="Effect">
				<Setter.Value>
					<DropShadowEffect BlurRadius="10"/>
				</Setter.Value>
			</Setter>
			<Setter Property="Background" Value="#4CF9F9F9"/>
		</Style>
	</UserControl.Resources>

	<UserControl.DataContext>
		<Binding Path="GroupAssociationTab"
				 Source="{StaticResource Locator}" />
	</UserControl.DataContext>

	<Grid x:Name="LayoutRoot">
		
		<i:Interaction.Triggers>
			<i:EventTrigger EventName="Loaded">
				<mvvmLightCommand:EventToCommand Command="{Binding InitializationCommand}" />
			</i:EventTrigger>
		</i:Interaction.Triggers>

		<!--Border.-->
		<Border HorizontalAlignment="Center" 				
				Margin="15,25,15,25"
				Padding="15,15,15,15"
				VerticalAlignment="Center"  
				BorderBrush="Black" Style="{StaticResource BorderStyleGroupAssociation}" 
				Background="#FFF9F9F9">
			
			<Grid>

				<!--General grid definition.-->
				<Grid.RowDefinitions>
					<RowDefinition/>
					<RowDefinition/>
					<RowDefinition/>
					<RowDefinition Height="Auto"/>
				</Grid.RowDefinitions>

				<!--View Group Correspondence synchronization between RIO and AD.-->

				<!--View title.-->
				<TextBlock Grid.Row="0"
						   TextWrapping="Wrap"
						   Text="{Binding LblGroupAssociationExplanation}"
						   FontWeight="Bold"
						   HorizontalAlignment="Center"
						   Margin="0,10,0,20"/>

				<!--Organization and ad configuration choice.-->
				<StackPanel Orientation="Horizontal"
							HorizontalAlignment="Center" 
							Grid.Row="1"
							d:LayoutOverrides="Height"
							Margin="20,20,20,20">
					
					<!--Organization choise.-->
					<TextBlock TextWrapping="Wrap"
							   Text="{Binding LblOrganization}"
							   FontWeight="Bold"/>

					<ComboBox x:Name="Cbb_Organization"	
							  Margin="10,0,0,0"
							  Width="250"
							  IsEnabled="{Binding CanSelectOrganization, Mode=TwoWay}"
							  ItemsSource="{Binding LstOrganization, Mode=TwoWay}"
							  DisplayMemberPath="Name"                              
							  SelectedValue="{Binding SelectedGroupOrganization, Mode=TwoWay}"/>
					
					<!--Ad configuration choice.-->
					<TextBlock TextWrapping="Wrap"
							   Text="{Binding LblConfiAd}"
							   FontWeight="Bold"
							   Margin="40,0,0,0"/>

					<ComboBox x:Name="Cbb_ADConfig"	
							  Margin="10,0,0,0"
							  Width="250"
							  IsEnabled="{Binding CanSelectAdConfig, Mode=TwoWay}"
							  ItemsSource="{Binding AdConfigCustomer, Mode=TwoWay}"
							  DisplayMemberPath="AdName"                              
							  SelectedValue="{Binding SelectedAdConfigCustomer, Mode=TwoWay}"/>

				</StackPanel>
				
				<!--Assocition part-->
				<StackPanel Orientation="Vertical"
							Grid.Row="2"
							d:LayoutOverrides="Height">

					<!--Grid to alignement display.-->
					<Grid>

						<!--Row grid definition.-->
						<Grid.RowDefinitions>
							<RowDefinition/>
							<RowDefinition/>
							<RowDefinition/>
							<RowDefinition Height="40"/>
							<RowDefinition/>
							<RowDefinition Height="20"/>
							<RowDefinition/>
							<RowDefinition Height="20"/>
							<RowDefinition/>
							<RowDefinition Height="20"/>
							<RowDefinition/>
							<RowDefinition Height="20"/>
							<RowDefinition/>
							<RowDefinition/>
						</Grid.RowDefinitions>

						<!--Column grid definition.-->
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="350"/>
							<ColumnDefinition Width="20"/>
							<ColumnDefinition Width="350"/>
							<ColumnDefinition Width="15"/>
							<ColumnDefinition Width="30"/>
							<ColumnDefinition Width="15"/>
							<ColumnDefinition Width="350"/>
						</Grid.ColumnDefinitions>

						<!--Fist line: Display User or group Ad.-->
						<StackPanel Grid.Row="0"
									Grid.Column="7"
									HorizontalAlignment="Center"
									Orientation="Horizontal"
									d:LayoutOverrides="Height">

							<RadioButton x:Name="RadioButtonUserAd"
										 GroupName="DisplayAdInformation" 
										 IsChecked="{Binding rdbUserAdIsChecked,Mode=TwoWay}" 
										 Margin="0,0,0,10"
										 FontWeight="Bold"
										 Content="{Binding rdbUserAdLabel}"/>

							<RadioButton x:Name="RadioButtonGroupAd"
										 GroupName="DisplayAdInformation"                                     
										 IsChecked="{Binding rdbGroupAdIsChecked, Mode=TwoWay}"
										 Margin="10,0,0,10"
										 FontWeight="Bold"
										 Content="{Binding rdbGroupAdLabel}"/>

						</StackPanel>

						<!--Seconde line: Display grid title.-->
						
						<!--Rio group grid.-->
						<TextBlock Grid.Row="1"
								   Grid.Column="0"
								   HorizontalAlignment="Center"
								   TextWrapping="Wrap"
								   Text="{Binding LblGridGroupRioTitle}"
								   FontWeight="Bold"/>

						<!--Rio association group and user grid.-->
						<TextBlock Grid.Row="1"
								   Grid.Column="2"
								   HorizontalAlignment="Center"
								   TextWrapping="Wrap"
								   Text="{Binding LblGridRioAssociationADTitle}"
								   FontWeight="Bold"/>

						<!--Ad user and group grid.-->
						<TextBlock Grid.Row="1"
								   Grid.Column="7"
								   HorizontalAlignment="Center"
								   TextWrapping="Wrap"
								   Text="{Binding LblGridADTitle}"
								   FontWeight="Bold"/>

						<!--Third Line: The three grid-->
						
						<!--RIO Group Grid.-->
						<telerik:RadGridView x:Name="RadGridView_Oraganisation_RIO_Group"
											 Margin="0,10,0,0"
											 Grid.Row="2"
											 Grid.Column="0"
											 Grid.RowSpan="10"
											 AutoGenerateColumns="False"
											 CanUserFreezeColumns="False"
											 CanUserResizeColumns="False"
											 IsFilteringAllowed="True"
											 IsReadOnly="True" 
											 Height="250"
											 MaxHeight="250"                                         
											 RowIndicatorVisibility="Collapsed"
											 ShowGroupPanel="False" 
											 SelectionMode="Single"
											 ItemsSource="{Binding OrganizationRioGroupList, Mode=TwoWay}"
											 SelectionChanged="RadGridView_Oraganisation_RIO_Group_SelectionChanged"
											 SelectionChanging="RadGridView_Oraganisation_RIO_Group_SelectionChanging">  
							
							<telerik:RadGridView.Columns>
								<telerik:GridViewSelectColumn/>
								<telerik:GridViewImageColumn Header="{Binding GroupAssociationTab.HeaderGroupType, Source={StaticResource Locator}, Mode=OneWay}" 
															 DataMemberBinding="{Binding IsUser, Converter={StaticResource BooleanGroupRioTypeImageConverter}}" 
															 ImageHeight="20" 
															 ImageWidth="20" 
															 MinWidth="20"/>
								<telerik:GridViewDataColumn Header="{Binding GroupAssociationTab.HeaderGroupName, Source={StaticResource Locator}, Mode=OneWay}"
															DataMemberBinding="{Binding Name}"
															Width="265"/>                                
							</telerik:RadGridView.Columns>
							
						</telerik:RadGridView>

						<!--RIO Association Grid.-->
						<telerik:RadGridView x:Name="RadGridView_Information_RIO_Group_Mapped"
											 Margin="0,10,0,0"
											 Grid.Row="2"
											 Grid.Column="2"
											 Grid.RowSpan="10"
											 AutoGenerateColumns="False"
											 CanUserFreezeColumns="False"
											 CanUserResizeColumns="False"
											 IsFilteringAllowed="True"
											 IsReadOnly="True"		
											 Height="250"
											 MaxHeight="250"
											 RowIndicatorVisibility="Collapsed"
											 ShowGroupPanel="False" 
											 SelectionMode="Extended"
											 ItemsSource="{Binding AdObjectMappedList, Mode=TwoWay}"
											 SelectionChanged="RadGridView_Information_RIO_Group_Mapped_SelectionChanged">

							<telerik:RadGridView.Columns>
								<telerik:GridViewSelectColumn/>
								<telerik:GridViewImageColumn Header="{Binding GroupAssociationTab.HeaderGroupType, Source={StaticResource Locator}, Mode=OneWay}" 
															 DataMemberBinding="{Binding TypeOfAdObject, Converter={StaticResource AdObjectTypeGroupRioTypeImageConverter}}" 
															 ImageHeight="20" 
															 ImageWidth="20" 
															 MinWidth="20"/>
								<telerik:GridViewDataColumn Header="{Binding GroupAssociationTab.HeaderGroupName, Source={StaticResource Locator}, Mode=OneWay}"
															DataMemberBinding="{Binding DisplayName}"
															Width="265"/>
							</telerik:RadGridView.Columns>

						</telerik:RadGridView>

						<!--AD Information Grid.-->
						<telerik:RadGridView x:Name="RadGridView_Informations_Ad"
											 Margin="0,10,0,0"
											 Grid.Row="2"
											 Grid.Column="7"
											 Grid.RowSpan="10"
											 AutoGenerateColumns="False"
											 CanUserFreezeColumns="False"
											 CanUserResizeColumns="False"
											 IsFilteringAllowed="True"
											 IsReadOnly="True"
											 Height="250"
											 MaxHeight="250"                                             
											 RowIndicatorVisibility="Collapsed"
											 ShowGroupPanel="False" 
											 SelectionMode="Extended"
											 ItemsSource="{Binding AdObjectToMappedList, Mode=TwoWay}"
											 SelectionChanged="RadGridView_Informations_Ad_SelectionChanged"
                                             SelectionChanging="RadGridView_Informations_Ad_SelectionChanging">

							<telerik:RadGridView.Columns>
								<telerik:GridViewSelectColumn/>
								<telerik:GridViewImageColumn Header="{Binding GroupAssociationTab.HeaderGroupType, Source={StaticResource Locator}, Mode=OneWay}" 
															 DataMemberBinding="{Binding TypeOfAdObject, Converter={StaticResource AdObjectTypeGroupRioTypeImageConverter}}" 
															 ImageHeight="20" 
															 ImageWidth="20" 
															 MinWidth="20"/>
								<telerik:GridViewDataColumn Header="{Binding GroupAssociationTab.HeaderGroupName, Source={StaticResource Locator}, Mode=OneWay}"
															DataMemberBinding="{Binding DisplayName}"
															Width="265"/>
							</telerik:RadGridView.Columns>

						</telerik:RadGridView>

						<!--Display all buttons.-->
						
						<!--Button Association Add.-->
						<Button x:Name="Button_Association_Add"
								Grid.Row="4"
								Grid.Column="4"
								Content="&lt;"
								IsEnabled="{Binding CanAddAdItemToGroupRio, Mode=TwoWay}"
								Command="{Binding AssociationAddCommand}"/>

						<!--Button Association Add.-->
						<Button x:Name="Button_All_Association_Add"
								Grid.Row="6"
								Grid.Column="4"
								Content="&lt;&lt;"
								IsEnabled="{Binding CanAddAllAdItemToGroupRio, Mode=TwoWay}"
								Command="{Binding AssociationAddAllCommand}"/>

						<!--Button Association Add.-->
						<Button x:Name="Button_Association_Delete"
								Grid.Row="8"
								Grid.Column="4"
								Content=">"
								IsEnabled="{Binding CanDeleteGroupRioItem, Mode=TwoWay}"
								Command="{Binding AssociationDeleteCommand}"/>

						<!--Button Association Add.-->
						<Button x:Name="Button_All_Association_Delete"
								Grid.Row="10"
								Grid.Column="4"
								Content=">>"
								IsEnabled="{Binding CanDeleteAllGroupRioItem, Mode=TwoWay}"
								Command="{Binding AssociationDeleteAllCommand}"/>
					</Grid>

					<!--Button end part.-->
					<StackPanel Orientation="Horizontal"
							Grid.Row="4"
							d:LayoutOverrides="Height"
							Margin="0,0,0,0"
							HorizontalAlignment="Right">

						<!--Save Rio and AD correspondence button-->
						<Button x:Name="Button_Save"
								Content="{Binding GroupAssociationTab.BtnSave, Source={StaticResource Locator},Mode=OneWay}"   
								Margin="0,10,10,10"                                
								IsEnabled="{Binding CanSaveModification, Mode=TwoWay}"
								Command="{Binding SaveAssociationCommand}"/>

						<!--Close Rio and AD correspondence button-->
						<Button x:Name="Button_Cancel"
								Content="{Binding GroupAssociationTab.BtnCancelModification, Source={StaticResource Locator},Mode=OneWay}"
								Margin="0,10,10,10"
								IsEnabled="{Binding CanCancelModification, Mode=TwoWay}"
								Command="{Binding CancelAssociationCommand}"/>

						<!--Close Rio and AD correspondence button-->
						<Button x:Name="Button_Close"
								Content="{Binding GroupAssociationTab.BtnClose, Source={StaticResource Locator},Mode=OneWay}"
								Margin="0,10,20,10"
                                IsEnabled="{Binding CanClose, Mode=TwoWay}"
								Command="{Binding CloseAssociationCommand}"/>
						
					</StackPanel>

				</StackPanel>
                
                <telerik:RadBusyIndicator BusyContent=""
								  IsBusy="{Binding BusyIndicator.IsBusy, Mode=OneWay}"
								  Grid.RowSpan="2"
								  d:IsHidden="True"/>
                
            </Grid>

		</Border>

	</Grid>
	
</UserControl>
